package com.xxxx.yygh.hosp.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.xxxx.yygh.hosp.mapper.DictMapper;
import com.xxxx.yygh.model.cmn.Dict;
import com.xxxx.yygh.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

public class DictListener extends AnalysisEventListener<DictEeVo> {

    private DictMapper dictMapper;
    public DictListener(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    // 一行一行读取
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        // 将DictEevo实体转为Dict实体
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo, dict);
        // 如果不设为0 默认为1 则表示已被删除 所以不会被查出来 （小林发现的bug）
        dict.setIsDeleted(0);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
